package com.jiangruan.project;

import com.alibaba.fastjson.JSONObject;
import com.jiangruan.project.address.Address;
import com.jiangruan.project.bean.HotVideo;
import com.jiangruan.project.bean.HotVideoComm;
import com.jiangruan.project.request.HttpUtils;
import com.jiangruan.project.service.*;

import java.security.KeyPair;
import java.util.List;
import java.util.Scanner;

/**
 * @author:liangdu
 * @email:1487001474@qq.com
 * @desc:该类是Java项目的主函数的类，是程序的入口
 * datetime: 2021/12/8 0:03
 */
public class Main {


    public static void main(String[] args) {
     run();

    }
    public static void run(){
        System.out.println("=======比特币系统设计期末考察系统=======");
        System.out.println("本系统已实现以下功能：");
        System.out.println("1.热门视频 2. 和比特币客户端通信 3.比特币地址推到 0.退出");
        while (true){
            userMenu();
        }


    }
    public static void userMenu(){
        System.out.println("请输入要使用的功能");
        System.out.println("1.热门视频 2.和比特币客户端通信 3.比特币地址推到");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        switch (num){
            case 1://热门视频抓取
                HotVideoService hotvideo = new HotVideoService();
                List<HotVideo> videoList = hotvideo.getHotVideo();
                for (HotVideo video : videoList){
                    System.out.println(video.getShare_url());
                }
                break;
            case 2:

                String getchaintips = GetChainTips.getchaintips();
                System.out.println(getchaintips);
                break;
            case 3:
                Address address = new Address();
                KeyPair generatekey = address.generatekey();
                String addre  =   address.newAddress(generatekey);
                boolean isValid =  address.validateAddr(addre);
                System.out.println(isValid);
                System.out.println();
                break;
            case 0:
                System.out.println("谢谢使用");
                System.exit(0);
            default:
                System.out.println("输入有误，请重新输入");

                break;
        }
    }
}
